﻿<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="Forms.ascx.cs" Inherits="ERP.Modules.Forms" %>
<ext:Hidden ID="FormatTypeForm" runat="server" />
<%--------------GridForm-----------------%>
<ext:Panel ID="PanelForm" runat="server" Layout="Fit" Border="False">
    <Content>
        <ext:GridPanel
            ID="grForm"
            runat="server"
            Cls="grid-double"
            EnableColumnMove="true"
            Border="False">
            <Store>
                <ext:Store
                    ID="StoreForm"
                    runat="server"
                    OnReadData="StoreForm_RefreshData"
                    PageSize="20">
                    <Model>
                        <ext:Model runat="server" IDProperty="ID_Form" GroupField="Form_Name">
                            <Fields>
                                <ext:ModelField Name="ID_Form" Type="Int" />
                                <ext:ModelField Name="Form_Code" Type="String" />
                                <ext:ModelField Name="Form_Name" Type="String" />
                                <ext:ModelField Name="CreateDate" Type="Date" />
                                <ext:ModelField Name="AttFile" Type="String" />
                                <ext:ModelField Name="Note" Type="String" />
                            </Fields>
                        </ext:Model>
                    </Model>
                </ext:Store>
            </Store>
            <ColumnModel runat="server">
                <Columns>
                    <ext:RowNumbererColumn Text="STT" runat="server" Width="30" Align="Center" />
                    <ext:Column runat="server" Text="Mã biểu mẫu" Width="100" DataIndex="Form_Code"/>
                    <ext:Column runat="server" Text="Tên biểu mẫu" Width="250" DataIndex="Form_Name"/>
                    <ext:DateColumn runat="server" Text="Ngày tạo" Width="200" DataIndex="CreateDate" Format="dd-MM-yyyy" Align="Center"/>
                    <ext:Column runat="server" Text="Tệp tin" DataIndex="AttFile" Flex="1" Align="Left"/>
                </Columns>
            </ColumnModel>
            <Features>
                <ext:Grouping
                    runat="server" 
                    HideGroupedHeader="true"
                    GroupByText="Xem theo phân nhóm"
                    ShowGroupsText="Phân nhóm"
                    GroupHeaderTplString="{name} ({rows.length} danh mục con {[values.rows.length > 1 ? '' : '']})"
                    StartCollapsed="True" />
            </Features>
            <DirectEvents>
                <ItemDblClick OnEvent="FormDblClick">
                    <ExtraParams>
                        <ext:Parameter Name="ID_Form" Value="record.data.ID_Form" Mode="Raw" />
                    </ExtraParams>
                    <EventMask ShowMask="true" Msg="Đang tải..." />
                </ItemDblClick>
            </DirectEvents>
            <SelectionModel>
                <ext:CheckboxSelectionModel runat="server" Mode="Multi">
                    <Listeners>
                        <SelectionChange Handler="
                            if (selected.length == 0) {
                                #{btnEdit}.disable();
                                #{btnDel}.disable();
                                #{btnExport}.disable();
                            } else {
                                #{btnEdit}.enable();
                                #{btnDel}.enable();
                                #{btnExport}.enable();
                            }" />
                    </Listeners>
                </ext:CheckboxSelectionModel>
            </SelectionModel>
            <View>
                <ext:GridView runat="server" StripeRows="true" />
            </View>
            <DockedItems>
                <ext:Toolbar runat="server" Dock="Top">
                    <Items>
                        <ext:Button ID="btnAddNew" runat="server" Text="Thêm mới" Icon="ApplicationAdd">
                            <DirectEvents>
                                <Click OnEvent="btnAddNew_Click">
                                    <EventMask ShowMask="true" Msg="Đang tải..." />
                                </Click>
                            </DirectEvents>
                        </ext:Button>
                        <ext:ToolbarSeparator />
                        <ext:Button ID="btnEdit" runat="server" Text="Sửa" Icon="ApplicationEdit">
                            <DirectEvents>
                                <Click OnEvent="btnEdit_Click">
                                    <EventMask ShowMask="true" Msg="Đang tải..." />
                                </Click>
                            </DirectEvents>
                        </ext:Button>
                        <ext:ToolbarSeparator />
                        <ext:Button ID="btnDel" runat="server" Text="Xoá" Icon="ApplicationDelete">
                            <DirectEvents>
                                <Click OnEvent="btnDel_Click">
                                    <EventMask ShowMask="true" Msg="Đang tải..." />
                                    <ExtraParams>
                                        <ext:Parameter Name="name" Value="btnDel"></ext:Parameter>
                                    </ExtraParams>
                                    <Confirmation ConfirmRequest="true"
                                        Title="Thông Báo" Message="Bạn có muốn xoá mẫu tin này không ?">
                                    </Confirmation>
                                </Click>
                            </DirectEvents>
                        </ext:Button>
                        <ext:ToolbarSeparator />
                        <ext:Button ID="btnExport" runat="server" Text="Xuất tập tin" Icon="Printer">
                            <Menu>
                                <ext:Menu ID="MenuMain" runat="server">
                                    <Items>
                                        <ext:MenuItem ID="MenuItemExportXML" runat="server" Text="XML" Icon="PageCode">
                                            <Listeners>
                                                <Click Handler="submitValue(#{grOrderServicesMaintain}, #{FormatTypeOrderServicesMaintain}, 'xml');" />
                                            </Listeners>
                                        </ext:MenuItem>
                                    </Items>
                                </ext:Menu>
                            </Menu>
                        </ext:Button>
                    </Items>
                </ext:Toolbar>
                <ext:Toolbar runat="server" Dock="Bottom" AnchorHorizontal="100%">
                    <Items>
                        <ext:TriggerField ID="txtSearch" runat="server" Width="200" EnableKeyEvents="true" MarginSpec="0 8 0 0">
                            <Triggers>
                                <ext:FieldTrigger Icon="Search" />
                            </Triggers>
                            <DirectEvents>
                                <TriggerClick OnEvent="Search_Event">
                                        <EventMask ShowMask="true" Msg="Đang tải..." />
                                </TriggerClick>
                                <SpecialKey OnEvent="Search_Event" Before="return e.getKey() == Ext.EventObject.ENTER;">
                                        <EventMask ShowMask="true" Msg="Đang tải..." />
                                </SpecialKey>
                            </DirectEvents>
                        </ext:TriggerField>
                        <ext:PagingToolbar runat="server" StoreID="StoreForm" BeforePageText="Trang" AfterPageText="của {0}" LastText="Cuối" NextText="Kế tiếp" PrevText="Trở lại" FirstText="Đầu" RefreshText="Làm tươi" DisplayInfo="true" DisplayMsg="Trang {0} - {1} của {2}" />
                    </Items>
                </ext:Toolbar>
            </DockedItems>
        </ext:GridPanel>
    </Content>
</ext:Panel>
<ext:Panel runat="server">
    <Content>
        <%-----------WindowsForm-----------------%>
        <ext:Window ID="WindowsForm" runat="server"
            Title="Cập nhật biểu mẫu"
            Width="802"
            Height="528"
            Hidden="True"
            Region="Center"
            Modal="True"
            DefaultAnchor="100%"
            HideMode="Display"
            Border="False"
            Padding="5"
            DefaultButton="btnSavePopUp"
            Resizable="False">
            <Items>
                <ext:Toolbar runat="server">
                    <Items>
                        <ext:Button runat="server" Text="Lưu lại" Icon="Disk" ID="btnSavePopUp">
                            <DirectEvents>
                                <Click OnEvent="btnSavePopUp_Click" Before="return #{FormPanelForm}.isValid();">
                                    <EventMask ShowMask="true" Msg="Đang tải..." />
                                </Click>
                            </DirectEvents>
                        </ext:Button>
                        <ext:ToolbarSeparator />
                        <ext:Button runat="server" Text="Huỷ bỏ" Icon="Decline" ID="btnCancelPopUp">
                            <DirectEvents>
                                <Click OnEvent="btnCancelPopUp_Click">
                                    <EventMask ShowMask="true" Msg="Đang tải..." />
                                </Click>
                            </DirectEvents>
                        </ext:Button>
                    </Items>
                </ext:Toolbar>
                <ext:FormPanel ID="FormPanelForm" runat="server"
                    AutoHeight="true"
                    BodyPadding="10"
                    Frame="true"
                    DefaultAnchor="100%">
                    <Items>
                        <ext:TextField ID="txtID" runat="server" FieldLabel="ID" LabelAlign="Right" Hidden="true" />
                        <ext:TextField ID="txtForm_Code" runat="server" FieldLabel="Mã biểu mẫu" AnchorHorizontal="100%" AllowBlank="false" />
                        <ext:TextField ID="txtForm_Name" runat="server" FieldLabel="Tên biểu mẫu" AnchorHorizontal="100%" AllowBlank="false" />
                        <ext:DateField ID="txtCreateDate" runat="server" FieldLabel="Ngày tạo" AnchorHorizontal="100%" AllowBlank="false"/>
                        <ext:HtmlEditor ID="txtNote" runat="server" FieldLabel="Nội dung" AnchorHorizontal="100%" Height="360"/>
                    </Items>
                </ext:FormPanel>
            </Items>
        </ext:Window>
    </Content>
</ext:Panel>